package com.ccx.coachsite.task;

import org.json.JSONObject;

import android.content.Context;

import com.ccx.coachsite.http.BaseResp;
import com.ccx.coachsite.http.HttpCallBack;
import com.ccx.coachsite.http.HttpRequest;
import com.ccx.coachsite.http.UrlConfig;
import com.ccx.coachsite.util.Log;
import com.ccx.coachsite.util.SharedPreferencesUtil;
import com.ccx.coachsite.bus.Account;
import com.ccx.coachsite.bus.SharedKey;

public class RepasswordTask extends TaskBase 
{
	Account account;
	String newPwd;
	String code;
	String oldPwd;
	
	public RepasswordTask(HttpCallBack<BaseResp> iCall, Context context) {
		super(iCall, context);
		mTaskType = TaskType.TaskTypeRepassword;
	}
	
	public void setParams(Account account, String oldPwd, String newPwd, String code)
	{
		this.account = account;
		this.newPwd = newPwd;
		this.oldPwd = oldPwd;
		this.code = code;
	}
	
	protected void onDataParse(String responseString)
	{
		try {
			SharedPreferencesUtil.setValue(mContext,
					SharedKey.Shared_Password_Key, newPwd);
			
		} catch (Exception e) {
			Log.e(e.getMessage(), e);
		} finally {
		}
	}

	@Override
	protected String genUrl(HttpRequest request)
	{
		String url = UrlConfig.getUrlByKey(UrlConfig.RepasswordUrlKey) + 
				"?userId="+account.getUserId() + "&mobile="+account.getMobile()+"&code="+code+"&oldPassword="+oldPwd+"&newPassword="+newPwd;
		//request.addParameter("code", code);
		//request.addParameter("oldPassword", oldPwd);
		//request.addParameter("newPassword", oldPwd);
		
		return url;
	}
}
